package com.dragon8869.myspringboot.service.impl;

import com.dragon8869.myspringboot.entity.AyMood;
import com.dragon8869.myspringboot.mq.producer.AyMoodProducer;
import com.dragon8869.myspringboot.repository.AyMoodRepository;
import com.dragon8869.myspringboot.service.AyMoodService;
import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.jms.Destination;

@Service
public class AyMoodServiceImpl implements AyMoodService {

    @Resource
    AyMoodRepository ayMoodRepository;

    @Override
    public AyMood save(AyMood ayMood) {
        return ayMoodRepository.save(ayMood);
    }

    final static Destination DESTINATION = new ActiveMQQueue("ay.queue.asyn.save");

    @Resource
    AyMoodProducer ayMoodProducer;

    @Override
    public void ayncSave(AyMood ayMood) {
        ayMoodProducer.sendMessage(DESTINATION, ayMood);
    }
}
